//
//  LCUserCenterHeader.m
//  LongChain
//
//  Created by fengzi on 2018/7/1.
//  Copyright © 2018年 FengZi. All rights reserved.
//

#import "LCUserCenterHeader.h"

@implementation LCUserCenterHeader


- (void)updateUserCenterHeaderWithParameter:(id)parameter {
    
    
    NSString *account = [NSString stringWithFormat:@"%@",parameter[@"account"]];
//    NSString *middleStr = [account substringWithRange:NSMakeRange(3, 4)];
    account = [account stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"****"];
    NSString *temp = [NSString stringWithFormat:@"账号:%@",account];
    self.userAccount.text = temp;
    NSString *avatar = [NSString stringWithFormat:@"%@%@",BASEURL,parameter[@"avatar"]];
//    NSString *email = [NSString stringWithFormat:@"%@",parameter[@"email"]];
//    NSString *gender = [NSString stringWithFormat:@"%@",parameter[@"gender"]];
    NSString *nickname = [NSString stringWithFormat:@"%@",parameter[@"nickname"]];
    //  是否在线 0 无 1 有
    
    NSString *status = [NSString stringWithFormat:@"%@",parameter[@"status"]];
    NSString *onlineStatus = [status isEqualToString:@"1"] ? @"在线" : @"离线";
    self.userOnlineStatus.text = onlineStatus;
//    NSString *userid = [NSString stringWithFormat:@"%@",parameter[@"userid"]];

    [self.userHeaderImage sd_setImageWithURL:[NSURL URLWithString:avatar] placeholderImage:[UIImage imageNamed:@"userHeadImage"] options:SDWebImageRetryFailed];
    
    self.userHeaderImage.layer.cornerRadius = ((200 / 7) * 3) / 2;
    self.userHeaderImage.layer.masksToBounds = YES;
    self.userNickName.text = nickname;
    
    
    NSString *used_capacity = [NSString stringWithFormat:@"%@",parameter[@"used_capacity"]];
    NSString *capacity = [NSString stringWithFormat:@"%@",parameter[@"capacity"]];
    self.progressView.progress = (([used_capacity floatValue]) / 1024 / 1024) /
    (([capacity floatValue]) / 1024 / 1024);
    NSString *spaceUsedDes = [NSString stringWithFormat:@"使用空间:%ldGB/%ldGB",(([used_capacity integerValue]) / 1024 / 1024),(([capacity integerValue]) / 1024 / 1024)];
    self.spaceStatus.text = spaceUsedDes;
}

- (IBAction)uploadUserHeaderImage:(id)sender {
    if (self.uploadHeadImage) {
        self.uploadHeadImage(@"");
    }
    
}


@end
